<script type="text/javascript">
import Vue from 'vue'

function toast (type, text, width, position, params) {
  params = params === undefined ? {} : params
  Vue.$vux.toast.show({
    type: type,
    text: text,
    position: position === undefined ? 'middle' : position,
    width: width === undefined ? '7.6em' : width,
    time: params.time === undefined ? 2000 : params.time,
    isShowMask: params.isShowMask === undefined ? false : params.isShowMask,
    value: params.value === undefined ? false : params.value
  })
}

function text (text, width, position, params) {
  toast('text', text, width, position, params)
}

function success (text, width, position, params) {
  toast('success', text, width, position, params)
}

function warn (text, width, position, params) {
  toast('warn', text, width, position, params)
}

function cancel (text, width, position, params) {
  toast('cancel', text, width, position, params)
}

export default {
  text,
  success,
  warn,
  cancel
}
</script>